package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Raluca Puichilita on 03/08/2014.
 */
public class MovieManager {

    public static List<Movie> collectionOfAvailableMovies = new ArrayList<Movie>();
    public static List<Movie> collectionOfUnavailableMovies = new ArrayList<Movie>();

    public void populateListWithMovies() {
        collectionOfAvailableMovies.add(new Movie("The Shawshank Redemption", 1994, "Frank Darabont", 10));
        collectionOfAvailableMovies.add(new Movie("The Godfather", 1972, "Francis Ford Coppola", 9));
        collectionOfAvailableMovies.add(new Movie("Kill Bill", 2003, "Quentin Tarantino"));
        collectionOfAvailableMovies.add(new Movie("Titanic", 1997, "David Cameron", 10));
        collectionOfAvailableMovies.add(new Movie("Fight Club", 1999, "David Fincher", 8));
        collectionOfAvailableMovies.add(new Movie("Despicable Me", 2010, "Pierre Coffin", 7));
        collectionOfAvailableMovies.add(new Movie("Schindler's List", 1993, "Steven Spielberg"));
    }

    protected static void listAllMoviesFromCollection(List<Movie> movieList) {
        if (movieList.size() < 1)
            System.out.println("The are no available movies. Please try again later.");
        else
            for (Movie thisMovie : movieList) {
                System.out.print("(" + (movieList.indexOf(thisMovie) + 1) + ") ");
                System.out.println(thisMovie);
            }
    }

    protected static void checkoutMovie(int movieChoice) {
        Movie thisMovie = collectionOfAvailableMovies.get(movieChoice - 1);
        collectionOfAvailableMovies.remove(thisMovie);
        collectionOfUnavailableMovies.add(thisMovie);
        System.out.print("\n" + thisMovie + " has been successfully checked out!");
    }

    protected static void returnMovie(int choice) {
        Movie thisMovie = collectionOfUnavailableMovies.get(choice-1);
        collectionOfAvailableMovies.add(thisMovie);
        collectionOfUnavailableMovies.remove(thisMovie);
        System.out.print("\n" + thisMovie + " has been successfully returned!\n");
    }
}
